import axios from 'axios'
// import { gitApiPrefix } from '@/api/config.js'
const gitApiPrefix = 'http://172.20.20.81/api/v4'
// 查询所有的工程 groups?private_token=WxW99YvdqhHdJrDyQ_nw&per_page=50
export const findProjects = (params) => axios.get(`${gitApiPrefix}/projects?private_token=WxW99YvdqhHdJrDyQ_nw&order_by=updated_at&per_page=50&membership=true`, { params })
// 查询工程下面的所有分支
export const findBranchsByProject = (params) => axios.get(`${gitApiPrefix}/projects/${params.projectId}/repository/branches/?private_token=WxW99YvdqhHdJrDyQ_nw&per_page=50&order_by=updated_at`, { params })
// 查询2个分支是否存在差异
export const findCompareByProject = (params) => axios.get(`${gitApiPrefix}/projects/${params.projectId}/repository/compare?from=${params.from_branch}&to=${params.to_branch}&private_token=WxW99YvdqhHdJrDyQ_nw&force_refresh=true`, { params })
// 创建merge request
export const createMergeRequest = (params) => axios.post(`${gitApiPrefix}/projects/${params.projectId}/merge_requests/?private_token=WxW99YvdqhHdJrDyQ_nw`, params)
// 合并操作
export const acceptMergeRequest = (params) => axios.put(`${gitApiPrefix}/projects/${params.projectId}/merge_requests/${params.mrId}/merge/?private_token=WxW99YvdqhHdJrDyQ_nw`, params)
// 关闭merge request
export const closeMergeRequest = (params) => axios.put(`${gitApiPrefix}/projects/${params.projectId}/merge_requests/${params.mrId}/?private_token=WxW99YvdqhHdJrDyQ_nw&state_event=close`, params)
// 创建tag
export const createTagByProject = (params) => axios.post(`${gitApiPrefix}/projects/${params.projectId}/repository/tags/?private_token=WxW99YvdqhHdJrDyQ_nw`, params)
// 查询tag
export const findTagsByProject = (params) => axios.get(`${gitApiPrefix}/projects/${params.projectId}/repository/tags/?private_token=WxW99YvdqhHdJrDyQ_nw`)
// 删除tag
export const removeTagByProject = (params) => axios.delete(`${gitApiPrefix}/projects/${params.projectId}/repository/tags/${params.tagName}?private_token=sA1cAMxP7rYqosRz7DcG`, {})
// 查询merge request
export const findMergeRequest = (params) => axios.get(`${gitApiPrefix}/projects/${params.projectId}/merge_requests?search=${params.search}&state=opened&private_token=WxW99YvdqhHdJrDyQ_nw`)
// 查询指定工程提交信息
export const findCommitInfo = (params) => axios.get(`${gitApiPrefix}/projects/${params.projectId}/repository/commits/?private_token=WxW99YvdqhHdJrDyQ_nw&per_page=50`, { params })
// 查询merge request列表
export const findMergeRequestList = (params) => axios.get(`${gitApiPrefix}/projects/${params.projectId}/merge_requests?private_token=WxW99YvdqhHdJrDyQ_nw`, { params })

export const findMergeRequestChanges = (params) => axios.get(`${gitApiPrefix}/projects/${params.projectId}/merge_requests/${params.mrId}/changes?private_token=WxW99YvdqhHdJrDyQ_nw`, { params })

// 提交整体评论
export const postReviewComment = (params) => axios.post(`${gitApiPrefix}/projects/${params.projectId}/merge_requests/${params.mrId}/notes?private_token=WxW99YvdqhHdJrDyQ_nw`, params)

// 提交commit 评论
export const postReviewIssuse = (params) => axios.post(`${gitApiPrefix}/projects/${params.projectId}/repository/commits/${params.sha}/comments?private_token=WxW99YvdqhHdJrDyQ_nw`, params);

// export const postReviewIssuse = (params) => axios.post(`${gitApiPrefix}/projects/${params.projectId}/merge_requests/${params.mrId}/discussions?private_token=WxW99YvdqhHdJrDyQ_nw`, params);

// 查询merge 详情
export const findMergeRequestDetail = (params) => axios.get(`${gitApiPrefix}/projects/${params.projectId}/merge_requests/${params.mrId}?private_token=WxW99YvdqhHdJrDyQ_nw`)
